// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor*;

// import java.util.ArrayList;
// import java.util.std::list;

#include "SQLDropOfflineModelStatement.h"

#include "../SQLName.h"
#include "../SQLObject.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/instanceof.h"

SQLDropOfflineModelStatement::SQLDropOfflineModelStatement()
{
}

SQLDropOfflineModelStatement::SQLDropOfflineModelStatement(DbType_ptr dbType)
    : SQLStatementImpl(dbType)
{
}

void SQLDropOfflineModelStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLDropOfflineModelStatement)))
  {
    acceptChild(visitor, name);
  }
  visitor->endVisit(SharedObject(SQLDropOfflineModelStatement));
}

SQLObject_list_ptr SQLDropOfflineModelStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (name != NULL)
  {
    children->push_back(name);
  }
  return children;
}

SQLName_ptr SQLDropOfflineModelStatement::getName()
{
  return name;
}

void SQLDropOfflineModelStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

string_ptr SQLDropOfflineModelStatement::getTableGroupName()
{
  if (name == NULL)
  {
    return NULL;
  }

  // if (name instanceof SQLName*) {
  return name->getSimpleName();
  // }

  // return NULL;
}

BOOL_ptr SQLDropOfflineModelStatement::isIfExists()
{
  return ifExists;
}

void SQLDropOfflineModelStatement::setIfExists(BOOL_ptr ifNotExists)
{
  this->ifExists = ifNotExists;
}

BOOL_ptr SQLDropOfflineModelStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (name == expr)
  {
    setName(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}
